#ifndef BIT_UTILS_H
#define BIT_UTILS_H

#include <cstdint>

inline void convert_u32_to_u8array(uint32_t num, uint8_t arr[4])
{
    arr[0] = (num >> 24) & 0xFF;
    arr[1] = (num >> 16) & 0xFF;
    arr[2] = (num >> 8) & 0xFF;
    arr[3] = (num >> 0) & 0xFF;
}

inline void convert_u16_to_u8array(uint16_t num, uint8_t arr[2])
{
    arr[0] = (num >> 8) & 0xFF;
    arr[1] = (num >> 0) & 0xFF;
}

inline uint32_t convert_u8array_to_u32(uint8_t arr[4])
{
    uint32_t res = 0;
    res = (((uint32_t)arr[0]) << 24) + (((uint32_t)arr[1]) << 16)
          + (((uint32_t)arr[2]) << 8) + (((uint32_t)arr[3]) << 0);
    return res;
}

inline uint16_t convert_u8array_to_u16(uint8_t arr[2])
{
    uint16_t res = 0;
    res = ((uint16_t)arr[0] << 8) + ((uint16_t)arr[1] << 0);
    return res;
}

#endif // BIT_UTILS_H
